package ControlLayer;
import java.util.ArrayList;
import ModelLayer.*;



public class OrderCtr
{
    
    private OrderList orderList;
    private Order order;
    private CustomerList customerList;
    private Customer orderCustomer;
    private OrderProducts orderProducts;
    private ProductList productList;
    private DiscountList discountList;
    private Discount orderDiscount;
    
    public OrderCtr()
    {
       orderList = OrderList.getInstance();
       productList = ProductList.getInstance();
       discountList = DiscountList.getInstance();
    }
  
    public void createOrder(long orderId, String regDate, String delDate, int customerId)
    {
       customerList = CustomerList.getInstance();
       order = new Order(orderId, regDate, delDate);
       order.addCustomer(customerList.findCustomer(customerId));
       orderList.addOrder(order);
    }
    
    public void addProduct(int quantity, long orderId, int productId)
    {
        Product product = productList.findProduct(productId);
        orderProducts = new OrderProducts(product, quantity);
        orderList.findOrder(orderId).addProduct(orderProducts);
    }
    
    public void addDiscount (long discountId, long orderId)
    {
        Discount discount = discountList.findDiscount(discountId);
        orderList.findOrder(orderId).addDiscount(discount);
    }
    
    public void setStatus(String status, long orderId)
    {
        orderList.findOrder(orderId).setStatus(status);
    }
    
    public void setDelDate (String delDate, long orderId)
    {
        orderList.findOrder(orderId).setDelDate(delDate);
    }
    
    public void serRegDate(String regDate, long orderId)
    {
       orderList.findOrder(orderId).setRegDate(regDate);
    }
    
    public String getOrderDate(long orderId)
    {
       return orderList.findOrder(orderId).getOrderDate();
    }
    
    public String getDelDate(long orderId)
    {
        return orderList.findOrder(orderId).getDeliveryDate();
    }
    
    public long getOrderId(long orderId)
    {
        return orderList.findOrder(orderId).getOrderId();
    }
    
    public String getStatus(long orderId)
    {
        return orderList.findOrder(orderId).getStatus();
    }
    
    public double getInvoiceAmount(long orderId)
    {
        return orderList.findOrder(orderId).getInvoice();
    }
    
    public Order findOrder(long orderId)
    {
        return orderList.findOrder(orderId);
    }
    
    public void deleteOrder(long orderId)
    {
        boolean confirmDelete = false;
        orderList.deleteOrder(orderId);
        /*
         * if() delete conformation pop up function will be here
         */
    }
    
    
    
    
}
    


